package cn.xhy.module.purchase.dal.mysql.materialdemand;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.xhy.module.purchase.controller.admin.apply.vo.ProjectOrderPageReqVO;
import cn.xhy.module.purchase.dal.dataobject.materialdemand.ProjectOrderDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 项目物资申请单 Mapper
 *
 * @author xhy
 */
@Mapper
public interface ProjectOrderMapper extends BaseMapperX<ProjectOrderDO> {

    default List<ProjectOrderDO> selectListByDocumentNumber(String documentNumber) {
        return selectList(ProjectOrderDO::getDocumentNumber, documentNumber);
    }

    default int deleteByDocumentNumber(String documentNumber) {
        return delete(ProjectOrderDO::getDocumentNumber, documentNumber);
    }


    default PageResult<ProjectOrderDO> selectPage(ProjectOrderPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProjectOrderDO>()
                .eqIfPresent(ProjectOrderDO::getBelongingProject, reqVO.getBelongingProject())
                .betweenIfPresent(ProjectOrderDO::getETime, reqVO.getETime())
                .betweenIfPresent(ProjectOrderDO::getDocumentDate, reqVO.getDocumentDate())
                .eqIfPresent(ProjectOrderDO::getDocumentNumber, reqVO.getDocumentNumber())
                .eqIfPresent(ProjectOrderDO::getBarCode, reqVO.getBarCode())
                .eqIfPresent(ProjectOrderDO::getProductType, reqVO.getProductType())
                .eqIfPresent(ProjectOrderDO::getCategory, reqVO.getCategory())
                .likeIfPresent(ProjectOrderDO::getGname, reqVO.getGname())
                .eqIfPresent(ProjectOrderDO::getModel, reqVO.getModel())
                .eqIfPresent(ProjectOrderDO::getBrand, reqVO.getBrand())
                .eqIfPresent(ProjectOrderDO::getUnit, reqVO.getUnit())
                .eqIfPresent(ProjectOrderDO::getNumber, reqVO.getNumber())
                .eqIfPresent(ProjectOrderDO::getTechnicalParameter, reqVO.getTechnicalParameter())
                .eqIfPresent(ProjectOrderDO::getPrice, reqVO.getPrice())
                .eqIfPresent(ProjectOrderDO::getNotes, reqVO.getNotes())
                .likeIfPresent(ProjectOrderDO::getApplicantName, reqVO.getApplicantName())
                .betweenIfPresent(ProjectOrderDO::getApplicationDate, reqVO.getApplicationDate())
                .eqIfPresent(ProjectOrderDO::getBexamine, reqVO.getBexamine())
                .betweenIfPresent(ProjectOrderDO::getBexamineDate, reqVO.getBexamineDate())
                .eqIfPresent(ProjectOrderDO::getCexamine, reqVO.getCexamine())
                .betweenIfPresent(ProjectOrderDO::getCexamineDate, reqVO.getCexamineDate())
                .eqIfPresent(ProjectOrderDO::getBatchNumber, reqVO.getBatchNumber())
                .eqIfPresent(ProjectOrderDO::getPType, reqVO.getPType())
                .eqIfPresent(ProjectOrderDO::getIsOut, reqVO.getIsOut())
                .eqIfPresent(ProjectOrderDO::getBexamineNo, reqVO.getBexamineNo())
                .eqIfPresent(ProjectOrderDO::getCexamineNo, reqVO.getCexamineNo())
                .eqIfPresent(ProjectOrderDO::getSpecif, reqVO.getSpecif())
                .eqIfPresent(ProjectOrderDO::getSonId, reqVO.getSonId())
                .eqIfPresent(ProjectOrderDO::getParentId, reqVO.getParentId())
                .eqIfPresent(ProjectOrderDO::getInitialData, reqVO.getInitialData())
                .eqIfPresent(ProjectOrderDO::getBh, reqVO.getBh())
                .eqIfPresent(ProjectOrderDO::getIsCancel, reqVO.getIsCancel())
                .betweenIfPresent(ProjectOrderDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProjectOrderDO::getId));
    }

}
